﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace c__hw2
{   
    interface shape
    {
        double area { get; }
        bool islegal();

    }
    class rect : shape
    {
        protected int len;
        protected int wid;
        public double area { get { return len*wid;} }
        public rect(int wid,int len)
        {
            this.wid = wid;
            this.len = len;
        }
        virtual public bool islegal()
        {
            if (len > 0 && wid > 0) return true;
            else return false; 
        }
    }
    class Squa : rect
    {
        public Squa(int wid, int len):base(wid,len)
        {
           
        }
        override public bool  islegal()
        {
            if (len > 0 && wid > 0&&len==wid) return true;
            else return false;
        }
    }
    class tri : shape
    {
        protected int len1;
        protected int len2;
        protected int len3;
        public tri(int len1, int len2,int len3)
        {
            this.len1 = len1;
            this.len2 = len2;
            this.len3 = len3;
        }

        public double area { 
            get {
                int p = (len1 + len2 + len3 )/ 2;
                return Math.Sqrt(p*(p-len1)*(p-len2)*(p-len3));
            }
        }
        public bool islegal()
        {
            if (len1 > 0 && len2 > 0 && len3 > 0 && len1 + len2 > len3 && len1 + len3 > len2 && len3 + len2 > len1) return true;
            else return false;
        }
    }

    //形状工厂
    class shape_fac
    {
        public shape Get_shape(int arg)
        {
            Random rd = new Random();
            shape s = null;
            if (arg == 1) s =  new rect(rd.Next(1,100),rd.Next(1, 100));
            else if(arg == 2) s = new Squa(rd.Next(1,100),rd.Next(1, 100));
            else if(arg == 3)
                while (true)
                {
                    s = new tri(rd.Next(1, 100),rd.Next(1, 100),rd.Next(1, 100));
                    if (s.islegal()) break;
                }
            return s;
        }
    }

    internal class Program
    {   
        //输出素数因子
        static void print_su() {
            int x = int.Parse(Console.ReadLine());
            for(int i = 2; i < x; i++) {
                if (x % i == 0)
                {
                    bool flag = true;
                    for(int j = 2; j <= Math.Sqrt(i); j++) {
                        if (i != 2 && i % j == 0) flag = false;
                    }
                    if(flag) { Console.WriteLine(i); }
                }
            }
        }

        //数组操作
        static void arr(int[] a)
        {
            int max=int.MinValue, min=int.MaxValue,  sum=0;
            double avr;
            foreach(int i in a)
            {
                if (i > max) max = i;
                if (i < min) min = i;
                sum += i;
            }
            avr = Convert.ToDouble( sum )/ a.Length;
            Console.WriteLine(max);
            Console.WriteLine(min);
            Console.WriteLine(sum);
            Console.WriteLine(avr);
        }
        //埃式筛法
        static void ai_shai()
        {
            int[] arr = new int[100];
            for (int i = 0; i < arr.Length; i++) arr[i] = 1;
            for (int i = 2; i < arr.Length; i++)
            {
                if (arr[i] == 0) continue;
                for (int j = i + 1; j < arr.Length; j++)
                    if (arr[j] == 1 && j % i == 0) arr[j] = 0;
            }
            for (int i = 2; i < arr.Length; i++)
                if (arr[i] == 1) Console.WriteLine(i);
        }


        static void Main(string[] args)
        {
            print_su();
            int[] x = { 1, 2, 3, 4, 5, 5, };
            arr(x);
            ai_shai();
            Random rd = new Random();
            shape_fac fac = new shape_fac();
            double sum = 0;
            for(int i = 0; i < 10; i++)
            {
                shape s = fac.Get_shape(rd.Next(1,3));
                sum += s.area;
            }
            Console.WriteLine(sum);
            Console.ReadLine();
        }
    }
}
